package com.hxut.utils;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * description: WebConfig
 * date: 2022/6/14 12:11
 * author: MR.孙
 */
@Configuration
@CrossOrigin
public class WebConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").
                allowedHeaders("*").
                allowedMethods(new String[]{"GET","POST","PUT","DELETE"}).
                allowCredentials(true).
                allowedOrigins("http://localhost:8080",null).
                maxAge(3600);
    }
}
